<div class="container-fluid">
	<div id="pad-wrapper">
		<!-- products table-->
		<!-- the script for the toggle all checkboxes from header is located in js/theme.js -->
		<div class="table-wrapper products-table section">
			<div class="row-fluid head">
				<div class="span12">
					<h4>个人推广申请列表</h4>
				</div>
			</div>


			<form action="" method="get" name="search">
				<div class="row-fluid filter-block">
					<!--
					<div class="pull-left">
						<a class="btn-flat success" onclick="document.forms['batch'].submit();">批量通过</a>
					</div> -->
					<div class="pull-left">
						微信昵称：
						<input type="text" class="search" name="wx_name" value="<?php echo $wx_name?>"></input>
						起始时间：
						<input type="text" style="cursor: default" onclick="WdatePicker()" readonly="readonly" class="search" name="start_time" value="<?php echo $start_time?>"></input>
						结束时间：
						<input type="text" style="cursor: default" onclick="WdatePicker()" readonly="readonly" class="search" name="end_time" value="<?php echo $end_time?>"></input>
						<a class="btn-flat success" onclick="document.forms['search'].submit();">查询</a>
					</div>

					<div class="pull-right">
						<a class="btn-flat success" id="updateUserInfo">昵称及头像更新</a>
					</div>
				</div>
			</form>

			<div class="row-fluid">
				<table class="table table-hover">
					<thead>
					<tr>
						<!-- <th class="span3"><input type="checkbox" /> 头像</th> -->
						<th class="span1"><span class="line"></span> 头像</th>
						<th class="span2"><span class="line"></span>微信昵称</th>
						<th class="span3 clickable_time"><span class="line"></span>关注时间<span class="<?php
							if(!isset($_GET['sort_time'])){
								echo 'icon icon-chevron-down';
							} elseif($_GET['sort_time'] == 'asc') {
								echo 'icon icon-chevron-up';
							}elseif($_GET['sort_time'] == 'desc'){
								echo 'icon icon-chevron-down';
							}else{
								echo 'icon icon-chevron-down';
							}
							?>"></span></th>
						<th class="span1"><span class="line"></span>扫码数</th>
						<th class="span2 clickable" data-param=""><span class="line"></span>推广会员数<span class="<?php
                            if(!isset($_GET['sort_num'])){
                                echo 'icon icon-chevron-down';
                            } elseif($_GET['sort_num'] == 'asc') {
                                echo 'icon icon-chevron-up';
                            }elseif($_GET['sort_num'] == 'desc'){
                                echo 'icon icon-chevron-down';
                            }else{
                                echo 'icon icon-chevron-down';
                            }
                            ?>"></span></th>
						<th class="span2"><span class="line"></span>当前兑奖状态</th>
						<th class="span2"><span class="line"></span>操作</th>
					</tr>
					</thead>
					<form action="/organization-apply/batch" method="post" name="batch">
						<tbody>
						<?php if($list):?>
							<?php foreach ($list as $item):?>
								<!-- row -->
								<tr class="first">
									<td >
										<?php if($item['distributor'] == 4):?><input type="checkbox" name="spread_id[]" value="<?php echo $item['spread_id']?>"></input><?php endif;?>
										<img height="40" width="40" src="<?php echo $item['headimgurl']?>" />
									</td>
									<!-- <td class="mobile"><?php echo $item['mobile']?></td> -->
                                    <td class="wx_name"><?php echo $item['wx_name']?></td>
									<!-- <td class="email"><?php echo $item['email']?></td> -->
									<td class="create_time"><?php echo date('Y-m-d G:i:s',$item['create_time'])?></td>
									<!-- <td class="distributor"><?php if($item['distributor'] == 1){echo '待审核';} elseif($item['distributor'] == 2){echo '审核未通过';}elseif($item['distributor'] == 3){echo '审核通过';}?></td>  -->
									<!--
                                    <?php if($item['distributor'] == 4){ ?>
										<td class="description">-</td>
										<td class="description">-</td>
                                        <td class="description">
                                            <button type="button" class=" btn-flat primary" onclick="window.location.href='/spread/adopt?id=<?php echo $item['spread_id']?>'">审核</button></li>
                                        </td>
                                    <?php }elseif($item['distributor'] == 2){ ?>
										<td class="description">-</td>
										<td class="description">-</td>
                                        <td class="description">
                                            <button type="button" class=" btn-flat primary" onclick="window.location.href='/spread/info?id=<?php echo $item['spread_id']?>'">查看</button></li>
                                        </td>
                                    <?php }elseif(($item['distributor'] == 3 )||( $item['distributor'] == 1)){ ?> -->
										<td class="scanning_num"><?php echo $item['scanning_num']?></td>
										<td class="count"><a href="/scanqrc/index?openid=<?php echo $item['openid']?>&nickname=<?php echo $item['wx_name']?>"><?php echo $item['success_num']?></a></td>
										<td class="status"><?php
											if($item['grade_id'] == 0){
												echo "未兑奖";
											}else{
												echo $gradearr[$item['grade_id']];
											}
											?></td>
                                        <td class="options">
                                            <!-- <button type="button" class=" btn-flat primary" onclick="window.location.href='/spread/edit?id=<?php echo $item['spread_id']?>'">编辑</button></li> -->
											<!-- <button type="button" class=" btn-flat primary" onclick="window.location.href='/spread/info?id=<?php echo $item['spread_id']?>'">查看</button></li> -->
                                            <button type="button" class=" btn-flat primary" onclick="window.location.href='/spread/qrcode?id=<?php echo $item['spread_id']?>'">二维码</button></li>
											<button type="button" class=" btn-flat primary" onclick="window.location.href='/prizeinfo/index?id=<?php echo $item['spread_id']?>'">兑奖</button></li>
                                        </td>
                                    <!-- <?php } ?> -->
								</tr>
							<?php endforeach;?>
						<?php endif;?>
						</tbody>
					</form>
				</table>
			</div>
		</div>
		<!-- end products table -->
	</div>
	<div class="pagination pull-right">
		<?php echo $pagination;?>
	</div>
<!--Edited by ysy Start-->
	<script type="text/javascript">
		$(function () {
		<!--表格标题点击排序-->
		$("th.clickable").click(function () {
			var param=$(this).data("param" );
			if (!$("th.clickable .icon.icon-chevron-down").length>0) {
				$(this).find(".icon").addClass("icon-chevron-down").removeClass("icon-chevron-up");
				var  $namev = $('input[name="wx_name"]').val();
				var  $start_time = $('input[name="start_time"]').val();
				var  $end_time = $('input[name="end_time"]').val();
				var  $url = '/spread/index?wx_name='+$namev+"&sort_num=desc"+"&start_time="+$start_time+"&end_time="+$end_time;
				$.ajax({
					type:'get',
					url:$url,
					cache:false,
					dataType:'json',
					success:function(data){
//						window.location.reload($url);//刷新当前页面.
						location.href =$url;
					},
					error:function(){
//						window.location.reload($url);//刷新当前页面.
						location.href =$url;
					}
				});
			}
			else {
			$(this).find(".icon").addClass("icon-chevron-up").removeClass("icon-chevron-down");
				var  $namev = $('input[name="wx_name"]').val();
				var  $start_time = $('input[name="start_time"]').val();
				var  $end_time = $('input[name="end_time"]').val();
				var  $url = '/spread/index?wx_name='+$namev+"&sort_num=asc"+"&start_time="+$start_time+"&end_time="+$end_time;
				$.ajax({
					type:'get',
					url:$url,
					cache:false,
					dataType:'json',
					success:function(data){
//						window.location.reload($url);//刷新当前页面.
						location.href =$url;
					},
					error:function(){
//						window.location.reload($url);//刷新当前页面.
						location.href =$url;
					}
				});
				}
		});

		/*
		时间排序事件
		*/
		$("th.clickable_time").click(function () {
			var param=$(this).data("param" );
			if (!$("th.clickable_time .icon.icon-chevron-down").length>0) {
				$(this).find(".icon").addClass("icon-chevron-down").removeClass("icon-chevron-up");
				var  $namev = $('input[name="wx_name"]').val();
				var  $start_time = $('input[name="start_time"]').val();
				var  $end_time = $('input[name="end_time"]').val();

				var  $url = '/spread/index?wx_name='+$namev+"&sort_time=desc"+"&start_time="+$start_time+"&end_time="+$end_time;
				$.ajax({
					type:'get',
					url:$url,
					cache:false,
					dataType:'json',
					success:function(data){
//						window.location.reload($url);//刷新当前页面.
						location.href =$url;
					},
					error:function(){
//						window.location.reload($url);//刷新当前页面.
						location.href =$url;
					}
				});
			}
			else {
				$(this).find(".icon").addClass("icon-chevron-up").removeClass("icon-chevron-down");
				var  $namev = $('input[name="wx_name"]').val();
				var  $start_time = $('input[name="start_time"]').val();
				var  $end_time = $('input[name="end_time"]').val();
				var  $url = '/spread/index?wx_name='+$namev+"&sort_time=asc"+"&start_time="+$start_time+"&end_time="+$end_time;
				$.ajax({
					type:'get',
					url:$url,
					cache:false,
					dataType:'json',
					success:function(data){
						location.href =$url;
					},
					error:function(){
						location.href =$url;
					}
				});
			}
		});

		$("#updateUserInfo").click(
			function () {
				$("#updateUserInfo").html("更新中.......");
				$.ajax({
					type:'post',
					url:'/spread/updateuserinfo',
					cache:false,
					dataType:'json',
					success:function(data){

						if(data.result == 1)//success
						{
							window.location.reload();//刷新当前页面.
							$("#updateUserInfo").html("更新完成");
						}else{
							$("#updateUserInfo").html("更新完成,失败");
						}
					},
					error:function(){
						alert("失败");
						$("#updateUserInfo").html("更新完成,失败");
					}
				});
			}
		);
		});
	</script>
	<style>
		th{
			text-align: center !important;
		}
        table td{
            text-align: center !important;
        }
		table th span.line{
			left:0 !important;
		}
		th.clickable{
			cursor:pointer;
		}
		th.clickable_time{
			cursor:pointer;
		}
		th.clickable .icon{
			margin-left:10px;
		}
		th.clickable_time .icon{
			margin-left:10px;
		}
	</style>
<!--Edited by ysy End-->
</div>